<?php

/**
* Get Content
*
* Loads content item(s) from the content database
*
* @param string $var Variable name in array
* @param int $type The content type (required)
* @param int $id The content ID
* @param int|array $topic The topic ID like "X" or "X|Y|Z"
* @param string $keyword Perform a fulltext search on the database
* @param string $sort The column to sort by
* @param string $sort_dir The direction, ASC or DESC, to sort
* @param int $limit The number of items to pull
* @param int $offset Database offset
*
*/

function smarty_block_login ($params, $tagdata, &$smarty, &$repeat) { 
	if (!isset($params['var'])) {
		die();
	}
	else{
		if($params['type']=='login_form'){
			$html ='';
			$html .='<div class="box-login">';
			if ($smarty->CI->users_model->logged_in()){
				$html .=  'Xin chào: <strong>'.$smarty->CI->users_model->get('username').'</strong> Vip : <strong >'.$smarty->CI->users_model->dayvip().'</strong> ngày   <a href="'.site_url('logout').'" title="Thoát">Thoát</a>';
			}else{
				$html .='<form method="post" name="user_login" onsubmit="return checkLogin();" action="'.site_url('user_login').'" >';
				$html .='<div class="input-box">';
				$html .='<lable for="username">Tài khoản</lable>';
				$html .='<input type="text" onfocus="if(this.value==\'Tên đăng nhập\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Tên đăng nhập\'" value="Tên đăng nhập" id="username" name="username" class="input">';
				$html .='</div>';
				$html .='<div class="input-box">';
				$html .='<lable for="password">Tài khoản</lable>';
				$html .='<input type="password" onfocus="if(this.value==\'Mật khẩu\')this.value=\'\'" onblur="if(this.value==\'\')this.value=\'Mật khẩu\'" value="Mật khẩu"  name="password" id="password" class="input">';
				$html .='</div>';
				$html .='<div class="actions">';
				$html .='<button class="button" type="submit">';
				$html .='<span>Đăng nhập</span>';
				$html .='</button>';
				$html .='</div>';
				$html .='</form>';
			}
			$html .='</div>';
			$smarty->assign('login_form',$html);
		}elseif ($params['type']=='login_form_m'){
			if ($smarty->CI->users_model->logged_in()){
				$html .=  '<span>Xin chào: <b class="den">'.$smarty->CI->users_model->get('username').'</b> Vip : <b class="den">'.$smarty->CI->users_model->dayvip().'</b> ngày <a href="'.site_url('logout').'" >Thoát</a></span>';
			}
			$smarty->assign('login_form',$html);
		}
	}
	echo $tagdata;
}